package view.listener;

import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

import run.Activator;
import singleton.Singleton;
import view.views.CSADView;
import controller.UseCaseController;

public class CommentListener implements Listener {

	private final String id;
	private final UseCaseController useCaseController;
	private final CSADView view;
	private final int i;

	public CommentListener(String id, CSADView view,
			UseCaseController useCaseController, int i) {
		this.id = id;
		this.view = view;
		this.useCaseController = useCaseController;
		this.i = i;
	}

	public void handleEvent(Event event) {
		Singleton.getInstance().setListPos(i);
		Singleton.getInstance().setCommentPrevious(view.listOfData.get(i).getComments());
		Singleton.getInstance().setCommentText(view.searchString
				+ " - "
				+ view.listOfData.get(Singleton.getInstance().getPosition()).getRevision()
						.getHeader() + " ("
				+ Singleton.getInstance().getSelectedTab().getTabItemName()
				+ ")");
		useCaseController.setId(id);
		view.setEditorCom(view.refreshCommentEditor(view.getEditorCom(),
				"muster.mene"));
	}

}
